package com.corona.game.util;

import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.Pixmap;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.TextureData;
import com.badlogic.gdx.graphics.g2d.Batch;

/* loaded from: pokewilds.jar:com/pkmngen/game/util/SmolSpriteProxy.class */
public class SmolSpriteProxy extends SmolSprite {
    public boolean darkenColors1;
    public boolean darkenColors2;
    public boolean darkenColors3;
    public boolean lightenColors1;
    public boolean lightenColors2;
    public Color color1;
    public Color color2;
    public Color black;
    Texture originalTexture;
    Texture inverseTexture;
    Texture darkenTexture1;
    Texture darkenTexture2;
    Texture darkenTexture3;
    Texture lightenTexture1;
    Texture lightenTexture2;
    Texture confuseRayTexture1;
    Texture confuseRayTexture2;
    public static boolean inverseColors = false;
    public static boolean darkenAllColors1 = false;
    public static boolean darkenAllColors2 = false;
    public static boolean darkenAllColors3 = false;
    public static boolean confuseRayColors1 = false;
    public static boolean confuseRayColors2 = false;
    public static boolean lightenAllColors1 = false;
    public static boolean lightenAllColors2 = false;

    @Override // com.corona.game.util.SmolSprite
    public void draw(Batch batch) {
        Texture texture = getTexture();
        if (SpriteProxy.inverseColors) {
            setTexture(this.inverseTexture);
            texture = this.inverseTexture;
        } else if (!SpriteProxy.inverseColors && texture == this.inverseTexture) {
            setTexture(this.originalTexture);
            texture = this.originalTexture;
        }
        if (SpriteProxy.darkenAllColors1 && texture == this.originalTexture) {
            setTexture(this.darkenTexture1);
            texture = this.darkenTexture1;
        } else if (!SpriteProxy.darkenAllColors1 && texture == this.darkenTexture1) {
            setTexture(this.originalTexture);
            texture = this.originalTexture;
        }
        if (SpriteProxy.darkenAllColors2 && texture == this.originalTexture) {
            setTexture(this.darkenTexture2);
            texture = this.darkenTexture2;
        } else if (!SpriteProxy.darkenAllColors2 && texture == this.darkenTexture2) {
            setTexture(this.originalTexture);
            texture = this.originalTexture;
        }
        if (SpriteProxy.darkenAllColors3 && texture == this.originalTexture) {
            setTexture(this.darkenTexture3);
            texture = this.darkenTexture3;
        } else if (!SpriteProxy.darkenAllColors3 && texture == this.darkenTexture3) {
            setTexture(this.originalTexture);
            texture = this.originalTexture;
        }
        if (SpriteProxy.lightenAllColors1 && texture == this.originalTexture) {
            setTexture(this.lightenTexture1);
            texture = this.lightenTexture1;
        } else if (!SpriteProxy.lightenAllColors1 && texture == this.lightenTexture1) {
            setTexture(this.originalTexture);
            texture = this.originalTexture;
        }
        if (SpriteProxy.lightenAllColors2 && texture == this.originalTexture) {
            setTexture(this.lightenTexture2);
            texture = this.lightenTexture2;
        } else if (!SpriteProxy.lightenAllColors2 && texture == this.lightenTexture2) {
            setTexture(this.originalTexture);
            texture = this.originalTexture;
        }
        if (this.lightenColors1 && texture == this.originalTexture) {
            setTexture(this.lightenTexture1);
            texture = this.lightenTexture1;
        } else if (!this.lightenColors1 && !SpriteProxy.lightenAllColors1 && texture == this.lightenTexture1) {
            setTexture(this.originalTexture);
            texture = this.originalTexture;
        }
        if (this.lightenColors2 && texture == this.originalTexture) {
            setTexture(this.lightenTexture2);
            texture = this.lightenTexture2;
        } else if (!this.lightenColors2 && !SpriteProxy.lightenAllColors2 && texture == this.lightenTexture2) {
            setTexture(this.originalTexture);
            texture = this.originalTexture;
        }
        if (SpriteProxy.confuseRayColors1 && texture == this.originalTexture) {
            setTexture(this.confuseRayTexture1);
            texture = this.confuseRayTexture1;
        } else if (!SpriteProxy.confuseRayColors1 && texture == this.confuseRayTexture1) {
            setTexture(this.originalTexture);
            texture = this.originalTexture;
        }
        if (SpriteProxy.confuseRayColors2 && texture == this.originalTexture) {
            setTexture(this.confuseRayTexture2);
            texture = this.confuseRayTexture2;
        } else if (!SpriteProxy.confuseRayColors2 && texture == this.confuseRayTexture2) {
            setTexture(this.originalTexture);
            texture = this.originalTexture;
        }
        if (this.darkenColors1 && texture == this.originalTexture) {
            setTexture(this.darkenTexture1);
            texture = this.darkenTexture1;
        } else if (!this.lightenColors1 && !SpriteProxy.darkenAllColors1 && texture == this.darkenTexture1) {
            setTexture(this.originalTexture);
            texture = this.originalTexture;
        }
        if (this.darkenColors2 && texture == this.originalTexture) {
            setTexture(this.darkenTexture2);
            texture = this.darkenTexture2;
        } else if (!this.darkenColors2 && !SpriteProxy.darkenAllColors2 && texture == this.darkenTexture2) {
            setTexture(this.originalTexture);
            texture = this.originalTexture;
        }
        if (this.darkenColors3 && texture == this.originalTexture) {
            setTexture(this.darkenTexture3);
            Texture texture2 = this.darkenTexture3;
        } else if (!this.darkenColors3 && !SpriteProxy.darkenAllColors3 && texture == this.darkenTexture3) {
            setTexture(this.originalTexture);
            Texture texture3 = this.originalTexture;
        }
        draw(batch);
    }

    public SmolSpriteProxy(Texture texture, int srcX, int srcY, int srcWidth, int srcHeight) {
        this(null, texture, srcX, srcY, srcWidth, srcHeight);
    }

    public SmolSpriteProxy(Color color1, Texture texture, int srcX, int srcY, int srcWidth, int srcHeight) {
        this(color1, new Color(), texture, srcX, srcY, srcWidth, srcHeight);
    }

    public SmolSpriteProxy(Color color1, Color color2, Texture texture, int srcX, int srcY, int srcWidth, int srcHeight) {
        this(Color.BLACK, color1, new Color(), texture, srcX, srcY, srcWidth, srcHeight);
    }

    public SmolSpriteProxy(Color black, Color color1, Color color2, Texture texture, int srcX, int srcY, int srcWidth, int srcHeight) {
        super(texture, srcX, srcY, srcWidth, srcHeight);
        this.darkenColors1 = false;
        this.darkenColors2 = false;
        this.darkenColors3 = false;
        this.lightenColors1 = false;
        this.lightenColors2 = false;
        this.color1 = null;
        this.color2 = new Color();
        this.black = Color.BLACK;
        this.color1 = color1;
        this.color2 = color2;
        this.black = black;
        this.originalTexture = texture;
        if (!TextureCache.effectsTextMap.containsKey(texture)) {
            Texture[] textures = new Texture[8];
            TextureData temp = texture.getTextureData();
            if (!temp.isPrepared()) {
                temp.prepare();
            }
            Pixmap currPixmap = temp.consumePixmap();
            Pixmap newPixmap = new Pixmap(texture.getWidth(), texture.getHeight(), Pixmap.Format.RGBA8888);
            newPixmap.setColor(new Color(0.0f, 0.0f, 0.0f, 0.0f));
            newPixmap.fill();
            int i = 0;
            int j = 0;
            while (j < texture.getHeight()) {
                if (i > texture.getWidth()) {
                    i = -1;
                    j++;
                } else {
                    Color color = new Color(currPixmap.getPixel(i, j));
                    if (!((color.r == 0.0f && color.g == 0.9843137f && color.b == 0.0f) || ((color.r == 0.0f && color.g == 0.0f && color.b == 0.0f) || (color.r == 1.0f && color.g == 1.0f && color.b == 1.0f)))) {
                        if (this.color1 == null) {
                            this.color1 = color;
                        } else if (color.r != this.color1.r || color.g != this.color1.g || color.b != this.color1.b) {
                            this.color2 = color;
                            break;
                        }
                    }
                }
                i++;
            }
            if (!(this.color1 == null || this.color2 == null || this.color1.r + this.color1.g + this.color1.b >= this.color2.r + this.color2.g + this.color2.b)) {
                Color tempColor = this.color1;
                this.color1 = this.color2;
                this.color2 = tempColor;
            }
            TextureCache.colorsTextMap.put(texture, new Color[]{this.color1, this.color2});
            int i2 = 0;
            int j2 = 0;
            while (j2 < texture.getHeight()) {
                if (i2 > texture.getWidth()) {
                    i2 = -1;
                    j2++;
                } else {
                    Color color3 = new Color(currPixmap.getPixel(i2, j2));
                    if (color3.a == 0.0f) {
                        color3 = new Color(0.0f, 0.0f, 0.0f, 0.0f);
                    } else if (color3.r == 0.0f && color3.g == 0.0f && color3.b == 0.0f) {
                        color3 = Color.WHITE;
                    } else if (color3.r == 1.0f && color3.g == 1.0f && color3.b == 1.0f) {
                        color3 = this.black;
                    } else if (color3.r == 1.0f && color3.g == 0.9843137f && color3.b == 1.0f) {
                        color3 = this.black;
                    } else if (color3.r == this.color1.r && color3.g == this.color1.g && color3.b == this.color1.b) {
                        color3 = this.color2;
                    } else if (color3.r == this.color2.r && color3.g == this.color2.g && color3.b == this.color2.b) {
                        color3 = this.color1;
                    }
                    if (color3.a != 0.0f) {
                        newPixmap.drawPixel(i2, j2, Color.rgba8888(color3.r, color3.g, color3.b, 1.0f));
                    }
                }
                i2++;
            }
            textures[0] = TextureCache.get(newPixmap);
            Pixmap newPixmap2 = new Pixmap(texture.getWidth(), texture.getHeight(), Pixmap.Format.RGBA8888);
            newPixmap2.setColor(new Color(0.0f, 0.0f, 0.0f, 0.0f));
            newPixmap2.fill();
            int i3 = 0;
            int j3 = 0;
            while (j3 < texture.getHeight()) {
                if (i3 > texture.getWidth()) {
                    i3 = -1;
                    j3++;
                } else {
                    Color color4 = new Color(currPixmap.getPixel(i3, j3));
                    if (color4.a == 0.0f) {
                        color4 = new Color(0.0f, 0.0f, 0.0f, 0.0f);
                    } else if (!(color4.r == 0.0f && color4.g == 0.0f && color4.b == 0.0f) && (!(color4.r == 1.0f && color4.g == 1.0f && color4.b == 1.0f) && (!(color4.r == 1.0f && color4.g == 0.9843137f && color4.b == 1.0f) && this.color1 != null && color4.r == this.color2.r && color4.g == this.color2.g && color4.b == this.color2.b))) {
                        color4 = this.black;
                    }
                    if (color4.a != 0.0f) {
                        newPixmap2.drawPixel(i3, j3, Color.rgba8888(color4.r, color4.g, color4.b, 1.0f));
                    }
                }
                i3++;
            }
            textures[1] = TextureCache.get(newPixmap2);
            Pixmap newPixmap3 = new Pixmap(texture.getWidth(), texture.getHeight(), Pixmap.Format.RGBA8888);
            newPixmap3.setColor(new Color(0.0f, 0.0f, 0.0f, 0.0f));
            newPixmap3.fill();
            int i4 = 0;
            int j4 = 0;
            while (j4 < texture.getHeight()) {
                if (i4 > texture.getWidth()) {
                    i4 = -1;
                    j4++;
                } else {
                    Color color5 = new Color(currPixmap.getPixel(i4, j4));
                    if (color5.a == 0.0f) {
                        color5 = new Color(0.0f, 0.0f, 0.0f, 0.0f);
                    } else if (!((color5.r == 0.0f && color5.g == 0.0f && color5.b == 0.0f) || ((color5.r == 1.0f && color5.g == 1.0f && color5.b == 1.0f) || (color5.r == 1.0f && color5.g == 0.9843137f && color5.b == 1.0f)))) {
                        if (this.color1 != null && color5.r == this.color2.r && color5.g == this.color2.g && color5.b == this.color2.b) {
                            color5 = this.black;
                        } else if (this.color1 != null && color5.r == this.color1.r && color5.g == this.color1.g && color5.b == this.color1.b) {
                            color5 = this.color2;
                        }
                    }
                    if (color5.a != 0.0f) {
                        newPixmap3.drawPixel(i4, j4, Color.rgba8888(color5.r, color5.g, color5.b, 1.0f));
                    }
                }
                i4++;
            }
            textures[2] = TextureCache.get(newPixmap3);
            Pixmap newPixmap4 = new Pixmap(texture.getWidth(), texture.getHeight(), Pixmap.Format.RGBA8888);
            newPixmap4.setColor(new Color(0.0f, 0.0f, 0.0f, 0.0f));
            newPixmap4.fill();
            int i5 = 0;
            int j5 = 0;
            while (j5 < texture.getHeight()) {
                if (i5 > texture.getWidth()) {
                    i5 = -1;
                    j5++;
                } else {
                    Color color6 = new Color(currPixmap.getPixel(i5, j5));
                    if (color6.a == 0.0f) {
                        color6 = new Color(0.0f, 0.0f, 0.0f, 0.0f);
                    } else if (color6.r == 0.0f && color6.g == 0.0f && color6.b == 0.0f) {
                        color6 = this.color2;
                    } else if (!((color6.r == 1.0f && color6.g == 1.0f && color6.b == 1.0f) || (color6.r == 1.0f && color6.g == 0.9843137f && color6.b == 1.0f))) {
                        if (this.color1 != null && color6.r == this.color2.r && color6.g == this.color2.g && color6.b == this.color2.b) {
                            color6 = this.color1;
                        } else if (this.color1 != null && color6.r == this.color1.r && color6.g == this.color1.g && color6.b == this.color1.b) {
                            color6 = Color.WHITE;
                        }
                    }
                    if (color6.a != 0.0f) {
                        newPixmap4.drawPixel(i5, j5, Color.rgba8888(color6.r, color6.g, color6.b, 1.0f));
                    }
                }
                i5++;
            }
            textures[3] = TextureCache.get(newPixmap4);
            Pixmap newPixmap5 = new Pixmap(texture.getWidth(), texture.getHeight(), Pixmap.Format.RGBA8888);
            newPixmap5.setColor(new Color(0.0f, 0.0f, 0.0f, 0.0f));
            newPixmap5.fill();
            int i6 = 0;
            int j6 = 0;
            while (j6 < texture.getHeight()) {
                if (i6 > texture.getWidth()) {
                    i6 = -1;
                    j6++;
                } else {
                    Color color7 = new Color(currPixmap.getPixel(i6, j6));
                    if (color7.a == 0.0f) {
                        color7 = new Color(0.0f, 0.0f, 0.0f, 0.0f);
                    } else if (color7.r == 0.0f && color7.g == 0.0f && color7.b == 0.0f) {
                        color7 = this.color1;
                    } else if (!((color7.r == 1.0f && color7.g == 1.0f && color7.b == 1.0f) || (color7.r == 1.0f && color7.g == 0.9843137f && color7.b == 1.0f))) {
                        if (this.color1 != null && color7.r == this.color2.r && color7.g == this.color2.g && color7.b == this.color2.b) {
                            color7 = Color.WHITE;
                        } else if (this.color1 != null && color7.r == this.color1.r && color7.g == this.color1.g && color7.b == this.color1.b) {
                            color7 = Color.WHITE;
                        }
                    }
                    if (color7.a != 0.0f) {
                        newPixmap5.drawPixel(i6, j6, Color.rgba8888(color7.r, color7.g, color7.b, 1.0f));
                    }
                }
                i6++;
            }
            textures[4] = TextureCache.get(newPixmap5);
            Pixmap newPixmap6 = new Pixmap(texture.getWidth(), texture.getHeight(), Pixmap.Format.RGBA8888);
            newPixmap6.setColor(new Color(0.0f, 0.0f, 0.0f, 0.0f));
            newPixmap6.fill();
            int i7 = 0;
            int j7 = 0;
            while (j7 < texture.getHeight()) {
                if (i7 > texture.getWidth()) {
                    i7 = -1;
                    j7++;
                } else {
                    Color color8 = new Color(currPixmap.getPixel(i7, j7));
                    if (color8.a == 0.0f) {
                        color8 = new Color(0.0f, 0.0f, 0.0f, 0.0f);
                    } else if (color8.r == 0.0f && color8.g == 0.0f && color8.b == 0.0f) {
                        color8 = this.color1;
                    } else if (color8.r == 1.0f && color8.g == 1.0f && color8.b == 1.0f) {
                        color8 = this.black;
                    } else if (color8.r == 1.0f && color8.g == 0.9843137f && color8.b == 1.0f) {
                        color8 = this.black;
                    } else if (!(this.color1 != null && color8.r == this.color2.r && color8.g == this.color2.g && color8.b == this.color2.b) && this.color1 != null && color8.r == this.color1.r && color8.g == this.color1.g && color8.b == this.color1.b) {
                        color8 = Color.WHITE;
                    }
                    if (color8.a != 0.0f) {
                        newPixmap6.drawPixel(i7, j7, Color.rgba8888(color8.r, color8.g, color8.b, 1.0f));
                    }
                }
                i7++;
            }
            textures[5] = TextureCache.get(newPixmap6);
            Pixmap newPixmap7 = new Pixmap(texture.getWidth(), texture.getHeight(), Pixmap.Format.RGBA8888);
            newPixmap7.setColor(new Color(0.0f, 0.0f, 0.0f, 0.0f));
            newPixmap7.fill();
            int i8 = 0;
            int j8 = 0;
            while (j8 < texture.getHeight()) {
                if (i8 > texture.getWidth()) {
                    i8 = -1;
                    j8++;
                } else {
                    Color color9 = new Color(currPixmap.getPixel(i8, j8));
                    if (color9.a == 0.0f) {
                        color9 = new Color(0.0f, 0.0f, 0.0f, 0.0f);
                    } else if (color9.r == 0.0f && color9.g == 0.0f && color9.b == 0.0f) {
                        color9 = this.color2;
                    } else if (color9.r == 1.0f && color9.g == 1.0f && color9.b == 1.0f) {
                        color9 = this.black;
                    } else if (color9.r == 1.0f && color9.g == 0.9843137f && color9.b == 1.0f) {
                        color9 = this.black;
                    } else if (this.color1 != null && color9.r == this.color2.r && color9.g == this.color2.g && color9.b == this.color2.b) {
                        color9 = Color.WHITE;
                    } else if (this.color1 == null || color9.r != this.color1.r || color9.g != this.color1.g || color9.b == this.color1.b) {
                    }
                    if (color9.a != 0.0f) {
                        newPixmap7.drawPixel(i8, j8, Color.rgba8888(color9.r, color9.g, color9.b, 1.0f));
                    }
                }
                i8++;
            }
            textures[6] = TextureCache.get(newPixmap7);
            Pixmap newPixmap8 = new Pixmap(texture.getWidth(), texture.getHeight(), Pixmap.Format.RGBA8888);
            newPixmap8.setColor(new Color(0.0f, 0.0f, 0.0f, 0.0f));
            newPixmap8.fill();
            int i9 = 0;
            int j9 = 0;
            while (j9 < texture.getHeight()) {
                if (i9 > texture.getWidth()) {
                    i9 = -1;
                    j9++;
                } else {
                    Color color10 = new Color(currPixmap.getPixel(i9, j9));
                    if (color10.a == 0.0f) {
                        color10 = new Color(0.0f, 0.0f, 0.0f, 0.0f);
                    } else if (!((color10.r == 0.0f && color10.g == 0.0f && color10.b == 0.0f) || ((color10.r == 1.0f && color10.g == 1.0f && color10.b == 1.0f) || (color10.r == 1.0f && color10.g == 0.9843137f && color10.b == 1.0f)))) {
                        if (this.color1 != null && color10.r == this.color2.r && color10.g == this.color2.g && color10.b == this.color2.b) {
                            color10 = this.black;
                        } else if (this.color1 != null && color10.r == this.color1.r && color10.g == this.color1.g && color10.b == this.color1.b) {
                            color10 = this.black;
                        }
                    }
                    if (color10.a != 0.0f) {
                        newPixmap8.drawPixel(i9, j9, Color.rgba8888(color10.r, color10.g, color10.b, 1.0f));
                    }
                }
                i9++;
            }
            textures[7] = TextureCache.get(newPixmap8);
            TextureCache.effectsTextMap.put(texture, textures);
        } else {
            this.color1 = TextureCache.colorsTextMap.get(texture)[0];
            this.color2 = TextureCache.colorsTextMap.get(texture)[1];
        }
        this.inverseTexture = TextureCache.effectsTextMap.get(texture)[0];
        this.darkenTexture1 = TextureCache.effectsTextMap.get(texture)[1];
        this.darkenTexture2 = TextureCache.effectsTextMap.get(texture)[2];
        this.lightenTexture1 = TextureCache.effectsTextMap.get(texture)[3];
        this.lightenTexture2 = TextureCache.effectsTextMap.get(texture)[4];
        this.confuseRayTexture1 = TextureCache.effectsTextMap.get(texture)[5];
        this.confuseRayTexture2 = TextureCache.effectsTextMap.get(texture)[6];
        this.darkenTexture3 = TextureCache.effectsTextMap.get(texture)[7];
    }
}
